<?php
             
/**
 * admin actions.
 *
 * @package    phImageBuilder
 * @subpackage admin
 * @author     archer
 * @version    SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
 */
class phImageBuilderAdminActions extends sfActions
{
    /**
    * This is callback function for ImageBuilderWidget
    * 
    * @param sfWebRequest $request
    */
    public function executeSave(sfWebRequest $request)
    {
        $sModelName = $request->getParameter('model');
        if( !class_exists( $sModelName ) )
        {
            throw new Exception( 'Class ' . $sModelName . ' not found!' );
        }
                            
        $oModel = new $sModelName();
        $oModel = $oModel->getPeer()->retrieveByPK( intval($request->getParameter('id')) );
        
        if( !$oModel )
        {
            throw new Exception( 'Object from key ' . $request->getParameter('id') . 'is not retrieved!' );
        }
        
        $oModel->createThumb( $request->getParameter('name'), $request->getParameter('x'), $request->getParameter('y'), $request->getParameter('scale') );
        
        return $this->renderText('OK');
    }
}
